<div class="form_content">
    <header><h3>Add Member</h3></header>
    <div class="module_content">
        <form name="branchform" id="branchform" method="post" enctype="multipart/form-data" action="<?php echo base_url(); ?>secu/organization/doaddmember" onsubmit="return validateMemberForm()">
        <fieldset style="width:48%; float:left; margin-right: 3%;">
            <label>Division</label>
            <select name="division" id="division" onchange="filterZones(this.value);" style="width: 300px;">
                <option value="">Select Division</option>
                <option value="1" <?php echo ($_POST['division'] == 1)?"selected":""; ?>>Uda Palatha</option>
                <option value="2" <?php echo ($_POST['division'] == 2)?"selected":""; ?>>Doluwa</option>
            </select>
        </fieldset>
        <fieldset style="width:48%; float:left;">
            <label>Zone</label>
            <select name="zone" id="zone" onchange="filterBranches(this.value, $('#division').val())" style="width: 300px;">
                <option value="">Select Zone</option>
                <?php
                    foreach ($zones as $zone) :
                ?>
                <option value="<?php echo $zone['zoneid']; ?>"><?php echo $zone['zonename']; ?></option>
                <?php
                    endforeach;
                ?>
            </select>
        </fieldset>
        <fieldset style="width:48%; float:left; margin-right: 3%;">
            <label>Branch</label>
            <select name="branch" id="branch" onchange="filterOrgs(this.value, $('#division').val(), $('#zone').val())" style="width: 300px;">
                <option value="">Select Branch</option>
            </select>
        </fieldset>
        <fieldset style="width:48%; float:left;">
            <label>Organization</label>
            <select name="organization" id="organization" style="width: 300px;">
                <option value="">Select Branch</option>
            </select>
        </fieldset>
        <fieldset style="width:100%; float:left;">
            <label>Member</label>
            <input type="text" name="membername" id="membername" value="" />
        </fieldset>
        <fieldset style="width:100%; float:left;">
            <label>Member Address</label>
            <textarea name="memberaddr" id="memberaddr" cols="50" rows="10" style="height: 100px;"></textarea>
        </fieldset>
        <fieldset style="width:100%; float:left;">
            <label>Member Contact No.</label>
            <input type="text" name="membertel" id="membertel" value="" style="width: 200px;" />
        </fieldset>
        <fieldset style="width:48%; float:left; margin-right: 3%;">
            <label>Service Period</label>
            <!--<input type="text" name="memberservice" id="memberservice" value="" style="width: 390px;" />-->
            <select name="memberservice" id="memberservice" style="width: 200px;">
                <option value="">Select Service Period</option>
                <?php
                    for ($i = 1; $i <= 40; $i++) :
                ?>
                    <option value="<?php echo $i; ?>"><?php echo $i; ?> years</option>
                <?php
                    endfor;
                ?>
            </select>
        </fieldset>
        <fieldset style="width:48%; float:left;">
            <label>Designation</label>
            <!--<input type="text" name="designation" id="designation" value="" style="width: 390px;" />-->
            <select name="designation" id="designation" style="width: 200px;">
                <option value="">Select Designation</option>
                <?php
                    foreach ($designation_arr as $_designation) :
                ?>
                            <option value="<?php echo $_designation['designationid']; ?>"><?php echo $_designation['designationname']; ?></option>
                <?php
                    endforeach;
                ?>

            </select>
        </fieldset>
        <fieldset style="width:100%; float:left;">
            <label>Other Info</label>
            <textarea name="memberotherinfo" id="memberotherinfo" cols="70" rows="20" style="height: 130px;"></textarea>
        </fieldset>
        <fieldset style="width:100%; float:left;">
            <label>Profile Picture</label>
            <input type="file" name="memberprofilepic" id="memberprofilepic" size="80" />
        </fieldset>
        <fieldset style="width:100%; float:left;">
            <input type="submit" name="submit" id="submit" value="SAVE" />&nbsp;
            <input type="reset" name="reset" id="reset" value="RESET" />
        </fieldset>
        <div class="clear"></div>
        </form>
    </div>
</div>
<script language="javascript" type="text/javascript">
function validateMemberForm()
{
    var division = document.getElementById("division");
    var zone = document.getElementById("zone");
    var branch = document.getElementById("branch");
    var org = document.getElementById("organization");
    var orgcat = document.getElementById("orgcat");
    var membername = document.getElementById("membername");
    var memberaddr = document.getElementById("memberaddr");
    var membertel = document.getElementById("membertel");
    var memberservice = document.getElementById("memberservice");
    var designation = document.getElementById("designation");
    var memberotherinfo = document.getElementById("memberotherinfo");

    if(division.selectedIndex == 0)
    {
        alert("Division is required.")
        division.focus();
        return false;
    } else if(zone.selectedIndex == 0) {
        alert("Zone is required.")
        zone.focus();
        return false;
    } else if(branch.selectedIndex == 0) {
        alert("Branch is required.")
        branch.focus();
        return false;
    } else if(org.selectedIndex == 0) {
        alert("Organization is required.")
        org.focus();
        return false;
    } else if(membername.value == "") {
        alert("Member name is required.")
        membername.focus();
        return false;
    } else if(memberaddr.value == "") {
        alert("Member address is required.")
        memberaddr.focus();
        return false;
    } else if(membertel.value == "") {
        alert("Member's contact no is required.")
        membertel.focus();
        return false;
    } else if(memberservice.value == "") {
        alert("Member's service period is required.")
        memberservice.focus();
        return false;
    } else if(designation.value == "") {
        alert("Member's designation is required.")
        designation.focus();
        return false;
    } else {
        return true;
    }
}
</script>